package com.cheetah.start.common.task.runner;

import com.cheetah.start.module.monitor.service.impl.DingDingService;
import com.cheetah.start.module.monitor.service.impl.SendMsgService;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 启动运行
 *
 * @author Feel
 * @date 2021/11/10 19:25
 * @Description:
 */
@Component
@Order(value = 1)
public class StartRunner implements ApplicationRunner, DisposableBean {

    @Autowired
    private SendMsgService sendMsgService;
    @Autowired
    private DingDingService dingDingService;

    @Value("${spring.profiles.active}")
    private String active;

    /**
     * 运行
     *
     * @param args arg游戏
     * @throws Exception 异常
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {

    }


    /**
     * 摧毁
     *
     * @throws Exception 异常
     */
    @Override
    public void destroy() throws Exception {
        if ("pro".equals(active)) {
            dingDingService.dingMsg("系统停止运行");
        }
    }
}
